package com.bestow.basic.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.bestow.common.annotation.Log;
import com.bestow.common.core.controller.BaseController;
import com.bestow.common.core.domain.AjaxResult;
import com.bestow.common.enums.BusinessType;
import com.bestow.basic.domain.HlsCashflowType;
import com.bestow.basic.service.IHlsCashflowTypeService;
import com.bestow.common.utils.poi.ExcelUtil;
import com.bestow.common.core.page.TableDataInfo;

/**
 * 现金流类型Controller
 * 
 * @author liliu
 * @date 2022-09-07
 */
@RestController
@RequestMapping("/basic/hlsCashflowType")
public class HlsCashflowTypeController extends BaseController
{
    @Autowired
    private IHlsCashflowTypeService hlsCashflowTypeService;

    /**
     * 查询现金流类型列表
     */
    @PreAuthorize("@ss.hasPermi('basic:hlsCashflowType:list')")
    @GetMapping("/list")
    public TableDataInfo list(HlsCashflowType hlsCashflowType)
    {
        startPage();
        List<HlsCashflowType> list = hlsCashflowTypeService.selectHlsCashflowTypeList(hlsCashflowType);
        return getDataTable(list);
    }

    /**
     * 导出现金流类型列表
     */
    @PreAuthorize("@ss.hasPermi('basic:hlsCashflowType:export')")
    @Log(title = "现金流类型", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, HlsCashflowType hlsCashflowType)
    {
        List<HlsCashflowType> list = hlsCashflowTypeService.selectHlsCashflowTypeList(hlsCashflowType);
        ExcelUtil<HlsCashflowType> util = new ExcelUtil<HlsCashflowType>(HlsCashflowType.class);
        util.exportExcel(response, list, "现金流类型数据");
    }

    /**
     * 获取现金流类型详细信息
     */
    @PreAuthorize("@ss.hasPermi('basic:hlsCashflowType:query')")
    @GetMapping(value = "/{cfType}")
    public AjaxResult getInfo(@PathVariable("cfType") String cfType)
    {
        return AjaxResult.success(hlsCashflowTypeService.selectHlsCashflowTypeByCfType(cfType));
    }

    /**
     * 新增现金流类型
     */
    @PreAuthorize("@ss.hasPermi('basic:hlsCashflowType:add')")
    @Log(title = "现金流类型", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody HlsCashflowType hlsCashflowType)
    {
        return toAjax(hlsCashflowTypeService.insertHlsCashflowType(hlsCashflowType));
    }

    /**
     * 修改现金流类型
     */
    @PreAuthorize("@ss.hasPermi('basic:hlsCashflowType:edit')")
    @Log(title = "现金流类型", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody HlsCashflowType hlsCashflowType)
    {
        return toAjax(hlsCashflowTypeService.updateHlsCashflowType(hlsCashflowType));
    }

    /**
     * 删除现金流类型
     */
    @PreAuthorize("@ss.hasPermi('basic:hlsCashflowType:remove')")
    @Log(title = "现金流类型", businessType = BusinessType.DELETE)
	@DeleteMapping("/{cfTypes}")
    public AjaxResult remove(@PathVariable String[] cfTypes)
    {
        return toAjax(hlsCashflowTypeService.deleteHlsCashflowTypeByCfTypes(cfTypes));
    }
}
